﻿using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Linq;
using System.Collections.ObjectModel;
using System.Data.Services.Client;
using DoveSiButta.DSBServiceReference1;


namespace DoveSiButta
{
    public class MainViewModel : INotifyPropertyChanged
    {
        public MainViewModel()
        {
            this.Items = new ObservableCollection<ItemViewModel>();
            this.RifiutiTypes = new ObservableCollection<RifiutoType>();
        }

        
        /// <summary>
        /// A collection for ItemViewModel objects.
        /// </summary>
        public ObservableCollection<ItemViewModel> Items { get; private set; }
        public ObservableCollection<RifiutoType> RifiutiTypes { get; private set; }
        /*
        private string _sampleProperty = "Sample Runtime Property Value";
        /// <summary>
        /// Sample ViewModel property; this property is used in the view to display its value using a Binding
        /// </summary>
        /// <returns></returns>
        public string SampleProperty
        {
            get
            {
                return _sampleProperty;
            }
            set
            {
                if (value != _sampleProperty)
                {
                    _sampleProperty = value;
                    NotifyPropertyChanged("SampleProperty");
                }
            }
        }
        */
        public bool IsDataLoaded
        {
            get;
            private set;
        }




        /// <summary>
        /// Creates and adds a few ItemViewModel objects into the Items collection.
        /// </summary>
        public void LoadData()
        {
            // Sample data; replace with real data
            this.RifiutiTypes.Add(new RifiutoType() { type = "Plastica", code = 1, description = "Bottiglie e contenitori di plastica", icon = new Uri( "/Resources/Icons/Rifiuti/plastica_300px.png", UriKind.Relative) });
            this.RifiutiTypes.Add(new RifiutoType() { type = "Vetro", code = 2, description = "Contenitori in vetro", icon = new Uri( "/Resources/Icons/Rifiuti/vetro_300px.png", UriKind.Relative) });
            this.RifiutiTypes.Add(new RifiutoType() { type = "Alluminio", code = 3, description = "Lattine e barattoli", icon = new Uri( "/Resources/Icons/Rifiuti/lattina_300px.png", UriKind.Relative) });
            this.RifiutiTypes.Add(new RifiutoType() { type = "Generico", code = 4, description = "Rifiuti indifferenziati", icon = new Uri( "/Resources/Icons/Rifiuti/indifferenziata_300px.png", UriKind.Relative) });
            this.RifiutiTypes.Add(new RifiutoType() { type = "Umido", code = 5, description = "Avanzi di cucina", icon = new Uri( "/Resources/Icons/Rifiuti/organici_300px.png", UriKind.Relative) });
            this.RifiutiTypes.Add(new RifiutoType() { type = "Batterie", code = 6, description = "Batterie esaurite", icon = new Uri( "/Resources/Icons/Rifiuti/batterie_300px.png", UriKind.Relative) });
            this.RifiutiTypes.Add(new RifiutoType() { type = "Farmaci", code = 7, description = "Farmaci scaduti", icon = new Uri( "/Resources/Icons/Rifiuti/farmaci_300px.png", UriKind.Relative) });
            this.RifiutiTypes.Add(new RifiutoType() { type = "Ingombranti", code = 8, description = "Elettrodomestici e mobilio", icon = new Uri( "/Resources/Icons/Rifiuti/nettezzaurbana_300px.png", UriKind.Relative) });
            this.RifiutiTypes.Add(new RifiutoType() { type = "Carta", code = 9, description = "Giornali e riviste", icon = new Uri("/Resources/Icons/Rifiuti/carta_300px.png", UriKind.Relative) });
            //this.Items.Add(new ItemViewModel() { LineOne = "Farmaci", LineTwo = "Maecenas praesent accumsan bibendum", LineThree = "Facilisi faucibus habitant inceptos interdum lobortis nascetur pharetra placerat pulvinar sagittis senectus sociosqu" });
            //this.Items.Add(new ItemViewModel() { LineOne = "Alluminio", LineTwo = "Dictumst eleifend facilisi faucibus", LineThree = "Suscipit torquent ultrices vehicula volutpat maecenas praesent accumsan bibendum dictumst eleifend facilisi faucibus" });
            //this.Items.Add(new ItemViewModel() { LineOne = "Ingombranti", LineTwo = "Habitant inceptos interdum lobortis", LineThree = "Habitant inceptos interdum lobortis nascetur pharetra placerat pulvinar sagittis senectus sociosqu suscipit torquent" });
            //this.Items.Add(new ItemViewModel() { LineOne = "Generico", LineTwo = "Nascetur pharetra placerat pulvinar", LineThree = "Ultrices vehicula volutpat maecenas praesent accumsan bibendum dictumst eleifend facilisi faucibus habitant inceptos" });
            //this.Items.Add(new ItemViewModel() { LineOne = "Carta", LineTwo = "Maecenas praesent accumsan bibendum", LineThree = "Maecenas praesent accumsan bibendum dictumst eleifend facilisi faucibus habitant inceptos interdum lobortis nascetur" });
            //this.Items.Add(new ItemViewModel() { LineOne = "Umido", LineTwo = "Dictumst eleifend facilisi faucibus", LineThree = "Pharetra placerat pulvinar sagittis senectus sociosqu suscipit torquent ultrices vehicula volutpat maecenas praesent" });
            //this.Items.Add(new ItemViewModel() { LineOne = "Plastica", LineTwo = "Habitant inceptos interdum lobortis", LineThree = "Accumsan bibendum dictumst eleifend facilisi faucibus habitant inceptos interdum lobortis nascetur pharetra placerat" });
            //this.Items.Add(new ItemViewModel() { LineOne = "Batterie", LineTwo = "Nascetur pharetra placerat pulvinar", LineThree = "Pulvinar sagittis senectus sociosqu suscipit torquent ultrices vehicula volutpat maecenas praesent accumsan bibendum" });
            //this.Items.Add(new ItemViewModel() { LineOne = "Vetro", LineTwo = "Maecenas praesent accumsan bibendum", LineThree = "Facilisi faucibus habitant inceptos interdum lobortis nascetur pharetra placerat pulvinar sagittis senectus sociosqu" });
            ////this.Items.Add(new ItemViewModel() { LineOne = "runtime ten", LineTwo = "Dictumst eleifend facilisi faucibus", LineThree = "Suscipit torquent ultrices vehicula volutpat maecenas praesent accumsan bibendum dictumst eleifend facilisi faucibus" });
            
            this.IsDataLoaded = true;
        }

        public event PropertyChangedEventHandler PropertyChanged;
        private void NotifyPropertyChanged(String propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (null != handler)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}